package com.ishowcode.controller;

import com.ishowcode.Dao.User;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@CrossOrigin
@RestController
public class BlogRoleController {
    String adminAdd = "0xF3B0bfE14Ad5431e23c1372B28C0405Cc14dFBa7";
    @RequestMapping("/setUser")
    public HttpSession getUser(@RequestParam("useradd") String address, HttpSession session){
        User user = new User();
        user.setAddress(address);
        System.out.println(address);
        if (address.equals(adminAdd)) user.setRole(1);
        else user.setRole(0);
        session.setAttribute("userAdd",user);
        session.setMaxInactiveInterval(30*60);
        return session;
    }
}
